# -*- coding: utf-8 -*-
"""
Created on Thu Apr 23 09:12:09 2020

@author: 付说举于版筑之间
"""

import pandas as pd

import matplotlib.pyplot as plt
'''
df = pd.read_csv("dataS.csv")
df=df.rename(columns={"车数：12":"12 cars", "车数：15":"15 cars", "车数：18": "18 cars"})

#boxplot=dT.boxplot()
df.to_csv("dfSteps.csv",index=False)
print(df)
'''

df = pd.read_csv("dataT333.csv")
#df=df.rename(columns={"车数：12":"12 cars", "车数：15":"15 cars", "车数：18": "18 cars"})

#boxplot=dT.boxplot()
#df.to_csv("dfTime.csv",index=False)

#print(df)
boxplot=df.boxplot(grid=False)
#
#plt.ylabel("Time Consuming")
#plt.xlabel("Number of Cars")#我们设置横纵坐标的标题。
#plt.show()

def status(x) : 
    return pd.Series([x.count(),x.min(),x.idxmin(),x.quantile(.25),x.median(),
                      x.quantile(.75),x.mean(),x.max(),x.idxmax(),x.mad(),x.var(),
                      x.std(),x.skew(),x.kurt()],index=['总数','最小值','最小值位置','25%分位数',
                    '中位数','75%分位数','均值','最大值','最大值位数','平均绝对偏差','方差','标准差','偏度','峰度'])
'''
medianT=pd.DataFrame(df.median())
meanT=pd.DataFrame(df.mean())
maxT=pd.DataFrame(df.max())
minT=pd.DataFrame(df.min())

medianT.to_csv("medianT.csv",index=False)
meanT.to_csv("meanT.csv",index=False)
maxT.to_csv("maxT.csv",index=False)
minT.to_csv("minT.csv",index=False)
varT.to_csv("varT.csv",index=False)
'''
#print(pd.DataFrame(df.median()))
sampleT=pd.DataFrame(df.median())
varT=pd.DataFrame(df.var())
maxT=pd.DataFrame(df.max())
#minT=pd.DataFrame(df.min())
#meanT=pd.DataFrame(df.mean())

maxT.to_csv("maxT.csv")
sampleT.to_csv("sampleT.csv")
varT.to_csv("varT.csv")
#minT.to_csv("minT.csv")
#meanS.to_csv("meanS.csv")


df1=pd.read_csv("maxT.csv",index_col=0,names=["Number of Cars","Max Time"])
df2=pd.read_csv("sampleT.csv",index_col=0,names=["Number of Cars","Median Time"])
df3=pd.read_csv("varT.csv",index_col=0,names=["Number of Cars","Var of Time"])
#df4=pd.read_csv("minT.csv",index_col=0,names=["Number of Cars","Min Time"])
#df5=pd.read_csv("meanS.csv",index_col=0,names=["Number of Cars","Average Steps"])

#df3=pd.DataFrame(df2,)
frames = [df1,df2, df3]
result = pd.concat(frames,axis=1, sort=False)
result.to_csv("3in1s.csv")
result.plot()
plt.ylabel("Time Consuming(s)")

plt.show()